# 1. 可迭代对象 (Iterable)
class MyIterable:
    def __init__(self, start, end):
        self.start = start
        self.end = end

    def __iter__(self):
        return MyIterator(self.start, self.end)

# 2. 迭代器 (Iterator)
class MyIterator:
    def __init__(self, start, end):
        self.current = start
        self.end = end

    def __iter__(self):
        return self

    def __next__(self):
        if self.current >= self.end:
            raise StopIteration
        else:
            self.current += 1
            return self.current - 1

# 使用可迭代对象和迭代器
my_iterable = MyIterable(1, 5)
for num in my_iterable:
    print(f"Iterable/Iterator: {num}")

# 3. 生成器 (Generator)
def my_generator(start, end):
    current = start
    while current < end:
        yield current
        current += 1

# 使用生成器
gen = my_generator(1, 5)
for num in gen:
    print(f"Generator: {num}")